/**
 * *****************************************************************************
 * @file main.c
 *
 * @brief Main source file for the project
 * *****************************************************************************
 */

 /* include -------------------------------------------------------------------- */
#include "../Inc/main.h"
#include "../Inc/Tool.h"
#include "../Inc/branch.h"
#include <stdlib.h>
#include <Windows.h>


/* main ----------------------------------------------------------------------- */
int main(void) {
	//ProgressBar();

	uint32_t StudentNumber = 0;

	StudeStudentStructurent* student = (StudeStudentStructurent*)malloc(StudentNumber * sizeof(StudeStudentStructurent));;
	while (student == NULL) 
		student = (StudeStudentStructurent*)malloc(StudentNumber * sizeof(StudeStudentStructurent));

	uint16_t choice;
	printf("Welcome to Big Data Class 4 Student management system.\n");

	do {
		printf("Current number of students in the system:  %d\n\n", StudentNumber);
		printf("You can do the following:\n");
		printf("1. Add a new student\n");
		printf("2. Delete a student\n");
		printf("3. Search for a student\n");
		printf("4. Display all students' information\n");
		printf("0. Exit the system\n\n");

		printf("Please enter your choice: ");
		scanf("%d", &choice);
		switch (choice) {
		case 1:
			AddStudent(&student, &StudentNumber);
			break;
		case 2:
			//DeleteStudent(&student, &StudentNumber);
			break;
		case 3:
			//SearchStudent(&student, &StudentNumber);
			break;
		case 4:
			DisplayAllStudents(student, StudentNumber);
			break;
		case 0:
			goto a;
		default:
			printf("Invalid choice. Please try again.\n");
			break;
		}
		printf("\n1. Continue operation;\n");
		printf("2. Exit the system;\n\n");
		printf("Please enter your choice: ");
		scanf("%d", &choice);
	} while (choice == 1);	

a:	printf("System has exited. Goodbye!\n");
	exit(0);
	return 0;
}
